package com.ygqh.baby.model;

import java.math.BigDecimal;

public class OrderSkuTaxRates implements Cloneable {
    private Long orderId;

    private Long productId;

    private Long odId;
    private Long skuId;

    private Long quantity;

    private BigDecimal salePrice;

    private BigDecimal valueAddedTaxRate;

    private BigDecimal saleTaxRate;

    private BigDecimal tariffRate;

    /**
     * 倒推货值 （salePrice  含关税金额）
     *
     * @return BigDecimal
     */
    public BigDecimal getRealPrice() {
        return salePrice.divide(BigDecimal.ONE.add(getTariffRate()), 2, BigDecimal.ROUND_HALF_UP);
    }


    public BigDecimal getSingleValueAddedTax() {
        return salePrice.add(getSaleTaxRate()).multiply(getValueAddedTaxRate()).setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }

    /**
     * //增值税= （关税完税价格+关税+消费税）* 增值税税率
     *
     * @param salePrice 关税完税价格
     * @return BigDecimal
     */
    public BigDecimal getSingleValueAddedTax(BigDecimal salePrice) {
        return (salePrice.add(getSingleTariff()).add(getSingleSaleTax())).multiply(getValueAddedTaxRate()).setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }

    public BigDecimal getSingleSaleTax() {
        return BigDecimal.ZERO;
    }

    public BigDecimal getSingleTariff() {
        return salePrice.subtract(getRealPrice());
    }

    public Long getOdId() {
        return odId;
    }

    public void setOdId(Long odId) {
        this.odId = odId;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        this.skuId = skuId;
    }

    public Long getQuantity() {
        return quantity;
    }

    public void setQuantity(Long quantity) {
        this.quantity = quantity;
    }

    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
    }

    public BigDecimal getValueAddedTaxRate() {
        return valueAddedTaxRate.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_DOWN);
    }

    public void setValueAddedTaxRate(BigDecimal valueAddedTaxRate) {
        this.valueAddedTaxRate = valueAddedTaxRate;
    }

    public BigDecimal getSaleTaxRate() {
        return saleTaxRate.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_DOWN);
    }

    public void setSaleTaxRate(BigDecimal saleTaxRate) {
        this.saleTaxRate = saleTaxRate;
    }

    public BigDecimal getTariffRate() {
        return tariffRate.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_DOWN);
    }

    public void setTariffRate(BigDecimal tariffRate) {
        this.tariffRate = tariffRate;
    }


    @Override
    public OrderSkuTaxRates clone() {
        try {
            return (OrderSkuTaxRates) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }

}
